package com.zjy.basic.commonenum;

/**
 * 系统错误码
 */
public enum ErrorCode {

    SYSTEM_ERROR("1001","系统内部异常"),
    PAGE_ERROR("1002","分页错误"),
    CONTENT_AUDIT_FAILED("1003","百度智能审核失败"),
    IMAGE_CODE_TIME_OUT("1004","图形验证码过期"),
    IMAGE_CODE_ERROR("1005","图形验证码错误"),
    //微信跑路了的情况
    WECHAT_GG("1006","微信寄了"),
    //关于登录密码错误的情况;
    PASSWORD_ERROR("1007","密码错误"),
    CONFIRMPASSWORD_ERROR("1008","两次密码不一致"),
    //账号问题
    USER_NOT_FOUND("1009","账号信息不存在"),
    USER_REGISTERED("1010","该用户已被注册"),
    //查无此用户信息
    LOGININFO_NOT_FOUND("1011","用户信息异常，请重新登录");


    //错误码
    private String code;
    //错误信息
    private String msg;

    ErrorCode(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }
    public String getMsg() {
        return msg+"["+code+"]";
    }

    public static ErrorCode getByCode(String code){
        //获取ErrorCode中所有对象的数组
        ErrorCode[] errorCodes = ErrorCode.values();

        for (ErrorCode errorCode : errorCodes) {
            if(errorCode.getCode().equals(code)){
                return errorCode;
            }
        }
        return null;
    }
}